package com.baseweb.webadmin.core.constants;

import java.util.ArrayList;
import java.util.List;

public enum OrderPayStatus {
    NOT_PAY(-1,"未付款"), PAY_DEPOSIT(1,"已付定金,未付尾款"), PAY_ALL(2,"已付定金和尾款");

    private int code;
    private String name;
    OrderPayStatus(int code, String name){
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<OrderPayStatus> getAllData(){
        List<OrderPayStatus> result = new ArrayList<OrderPayStatus>();
        for (OrderPayStatus current : OrderPayStatus.values())
        {
            result.add(current);
        }
        return result;
    }

    public static OrderPayStatus getNameByCode(int code){
        List<OrderPayStatus> allData = getAllData();
        for (OrderPayStatus status : allData){
            if (status.getCode() == code){
                return status;
            }
        }
        return null;
    }

}
